Docker redis image
Published on 09.08.2016
From yesterday I'm in process of moving some of my services in new VPS which is based on latest Ubuntu LTS. Some of software that I'm using is "conterized" but not all of them. So moving to new VPS is time to fix that and Redis is first in my list. After quick research I figure out that I preffer to use Phusion base image for Redis also, instead of getting new images :) and because of that I update a little bit original Docker file to:
# Pull base image. FROM phusion/baseimage:0.9.19 # Install Redis. RUN \ cd /tmp && \ apt-get update && \ apt-get install wget -y &&\ apt-get install make -y && apt-get install gcc -y && \ wget http://download.redis.io/redis-stable.tar.gz && \ tar xvzf redis-stable.tar.gz && \ cd redis-stable && \ make && \ make install && \ cp -f src/redis-sentinel /usr/local/bin && \ mkdir -p /etc/redis && \ cp -f *.conf /etc/redis && \ rm -rf /tmp/redis-stable* && \ sed -i 's/^\(bind .*\)$/# \1/' /etc/redis/redis.conf && \ sed -i 's/^\(daemonize .*\)$/# \1/' /etc/redis/redis.conf && \ sed -i 's/^\(dir .*\)$/# \1\ndir \/data/' /etc/redis/redis.conf && \ sed -i 's/^\(logfile .*\)$/# \1/' /etc/redis/redis.conf # Define mountable directories. VOLUME ["/data"] # Define working directory. WORKDIR /data # Define default command. CMD ["redis-server", "/etc/redis/redis.conf"] # Expose ports. EXPOSE 6379So we can save this in some directory in
Dockerfile
after that we can user
docker build -t="dockerfile/redis" .Result will something like:
root@sylvester:/tmp/tt# docker images REPOSITORY TAG IMAGE ID CREATED SIZE dockerfile/redis latest fd12d74a4a9d 21 minutes ago 382.2 MB phusion/baseimage 0.9.19 c39664f3d4e5 4 weeks ago 225.6 MBThat is :) we can quickly use it with something like
docker run -d --name redis -p 6379:6379 dockerfile/redis redis-server --requirepass <password>Result will be:
root@sylvester:/tmp/tt# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 7efeb6befa28 dockerfile/redis "redis-server --requi" 11 minutes ago Up 11 minutes 0.0.0.0:6379->6379/tcp redisAnd woala we have fully functional Redis instance.
Happy codding